#!/usr/bin/env python
# encoding: utf-8
"""
@Author: Beam
@Mail:506556658@qq.com
@file: 生产消费者模型.py
@time: 2017/5/4 16:08
"""

import threading
import queue
import time

q = queue.Queue()
def producer():
    count = 1
    while True:
        q.put("骨头%s " % count )
        print("Beam 制造了第%s个骨头并丢了出来。。。" % count)
        count += 1
        time.sleep(2)
def consumer(name):
    while True:
        print('%s  捡到 %s，并且吃了。。'%(name,q.get()))
        time.sleep(6)
p = threading.Thread(target=producer,)
p.start()
c = threading.Thread(target=consumer,args=("Alex",))
c.start()


import os

os.getpid()